package main.java.org.mapper;

import main.java.Exam.pojo.Entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


@Mapper
public interface UserMapper {
    //检查账号是否存在
    @Select("SELECT id, username, password, real_name, gender, phone, role_id, class_id, status, is_deleted " +
            "FROM tb_user " +
            "WHERE username = #{username} " +
            "AND is_deleted = 0")
    public User selectByUsername(@Param("username") String username);
  //检查号码是否存在。如果存在说明注册过了
  @Select("select * from tb_user where phone = #{phone} and is_deleted = 0")
  User selectByPhone(String phone); // 检查手机号是否存在
//添加账号
    @Insert("insert into tb_user (username, password, real_name, gender, phone, role_id, class_id, status, is_deleted) " +
            "values (#{username}, #{password}, #{realName}, #{gender}, #{phone}, #{roleId}, #{classId}, #{status}, #{isDeleted})")
    void insert(User user); // 新增用户
}
